import axios from "axios";
import nprogress from "nprogress";
import "nprogress/nprogress.css";

const mockAjax = axios.create({
  baseURL: '/mock',
  timeout: 10000
})
// 添加请求拦截器
mockAjax.interceptors.request.use(function (config) {
  nprogress.start()
  return config;
});

// 添加响应拦截器
mockAjax.interceptors.response.use(function (response) {
  nprogress.done()
  return response.data;
}, function (error) {
  console.log(error);
  nprogress.done()
  return new Promise(() => {})
});


export default mockAjax